package com.example.smartcitymovie.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.smartcitymovie.R;
import com.example.smartcitymovie.bean.MovieMessageBean;
import com.example.smartcitymovie.bean.TheatreMessageBean;
import com.example.smartcitymovie.utils.OkHttpUtils;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;

import java.util.List;

public class BannerMovieTimesAdapter extends BannerAdapter<MovieMessageBean.DataBean, BannerMovieTimesAdapter.BannerViewHolder> {


    public BannerMovieTimesAdapter(List<MovieMessageBean.DataBean> datas) {
        super(datas);
    }

    @Override
    public BannerViewHolder onCreateHolder(ViewGroup viewGroup, int i) {

        View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.banner_movie_message_list_item_layout,null,false);
        view.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        return new BannerViewHolder(view);
    }

    @Override
    public void onBindView(BannerViewHolder bannerViewHolder, MovieMessageBean.DataBean dataBean, int i, int i1) {
        bannerViewHolder.TVMovieMessage.setText(dataBean.getName());
        bannerViewHolder.RBMovieScore.setRating(dataBean.getScore());
        Glide.with(bannerViewHolder.IVMovieCoverThree).load(dataBean.getCover()).placeholder(R.drawable.ic_baseline_broken_image_24).into(bannerViewHolder.IVMovieCoverThree);
    }

    class BannerViewHolder extends RecyclerView.ViewHolder {

        private ImageView IVMovieCoverThree;
        private TextView TVMovieMessage;
        private RatingBar RBMovieScore;

        public BannerViewHolder(@NonNull View itemView) {
            super(itemView);
            IVMovieCoverThree = (ImageView) itemView.findViewById(R.id.IV_MovieCoverThree);
            TVMovieMessage = (TextView) itemView.findViewById(R.id.TV_MovieMessage);
            RBMovieScore = (RatingBar) itemView.findViewById(R.id.RB_MovieScore);
        }
    }

}
